function post(target, refresh) {
    $.post(target, function(data) {
        $(refresh).replaceWith($(data).find(refresh));
        $('#events-by-user').replaceWith($(data).find('#events-by-user'));
    });
}

$(document).ready(function() {

    $(document).on('click', '.event-link, .event-delete', function(event) {
        event.preventDefault();
        post($(this).attr('href'), '#'+$(this).text()+' .events-by-class');
    });

    $(document).on('click', '.event-show, .event-mask, .event-unlink', function(event) {
        event.preventDefault();
        post($(this).attr('href'), $('.nav-pills .active a').attr('href')+' .events-by-class');
    });
});